/* 
Set directory 
*/

    global root 	ENTER DIRECTORY
                                
	global nrega 	$root\Analysis\Dta\NREGA

	global output 	ENTER DIRECTORY
	

use "$nrega\nrega_takeup.dta", clear


tab lrain, gen(lrain)


label var lbin1 "CY Days $<$13C"
label var lbin2 "CY Days 13-15C"
label var lbin3 "CY Days 15-17C"
label var lbin4 "CY Days 17-19C"
label var lbin5 "CY Days 19-21C"
label var lbin6 "CY Days 21-23C"
label var lbin7 "CY Days 23-25C"
label var lbin8 "CY Days 25-27C"
label var lbin9 "CY Days 27-29C"
label var lbin10 "CY Days $>$29C"

label var lnpersondays "Log Person Days"
label var lnhh_100 "Log HHs 100 Days"
label var lnexp_labor "Log Exp. Labor"
label var lnexp_material "Log Exp. Material"



*Figure 7

areg lnpersondays lbin1 lbin2 lbin4 lbin5 lbin6 lbin7 lbin8 lbin9 lbin10 lrain1 lrain3 lhumid1 lhumid4 i.year, absorb(gdistid) cluster(gdistid)
estimates store cT`table'C`col++'

foreach num of numlist 1 2 4 5 6 7 8 9 10{
gen bincoef`num' = _b[lbin`num']
gen bincoefcil`num' = _b[lbin`num'] - 1.96*_se[lbin`num']
gen bincoefciu`num' = _b[lbin`num'] + 1.96*_se[lbin`num']
}


gen bincoef3 = 0
gen bincoefcil3 = 0
gen bincoefciu3 = 0


preserve

keep bincoef* bincoefcil* bincoefciu*
gen id = _n

keep if id == 1

reshape long bincoef bincoefcil bincoefciu, i(id) j(ll1lbin)

label var bincoefcil "95% Confidence Interval"
label var bincoefciu "95% Confidence Interval"

label var ll1lbin "Daily Average Temperature (C)"

twoway (connected bincoefcil bincoefciu ll1lbin, astyle(ci ci) yline(0, lcolor(black))  mcolor(gray gray) lpattern(dash dash) lcolor(gray gray) sort) (connected bincoef ll1lbin, sort msymbol(O) lcolor(red) mcolor(red) ) ///
, graphregion(color(white)) plotregion(icolor(white)) ///
legend(order (6 5 3 2)  label(3 "Estimated Coefficient") label(1 "95% Confidence Interval")) ytitle("Log Person Days") ///
xlabel(1 "<13C" 2 "13-15C" 3 "15-17C" 4 "17-19C" 5 "19-21C" 6 "21-23C" 7 "23-25C" 8 "25-27C" 9 "27-29C" 10 ">29C") ylabel(-0.04(0.02)0.04, angle (30))   
graph export "$output/F7a.png", replace width(800) height(600)	

restore

drop bincoef* 	 

areg lnhh_100 lbin1 lbin2 lbin4 lbin5 lbin6 lbin7 lbin8 lbin9 lbin10 lrain1 lrain3 lhumid1 lhumid4 i.year, absorb(gdistid) cluster(gdistid)
estimates store cT`table'C`col++'

foreach num of numlist 1 2 4 5 6 7 8 9 10{
gen bincoef`num' = _b[lbin`num']
gen bincoefcil`num' = _b[lbin`num'] - 1.96*_se[lbin`num']
gen bincoefciu`num' = _b[lbin`num'] + 1.96*_se[lbin`num']
}


gen bincoef3 = 0
gen bincoefcil3 = 0
gen bincoefciu3 = 0


preserve

keep bincoef* bincoefcil* bincoefciu*
gen id = _n

keep if id == 1

reshape long bincoef bincoefcil bincoefciu, i(id) j(ll1lbin)

label var bincoefcil "95% Confidence Interval"
label var bincoefciu "95% Confidence Interval"

label var ll1lbin "Daily Average Temperature (C)"

twoway (connected bincoefcil bincoefciu ll1lbin, astyle(ci ci) yline(0, lcolor(black))  mcolor(gray gray) lpattern(dash dash) lcolor(gray gray) sort) (connected bincoef ll1lbin, sort msymbol(O) lcolor(red) mcolor(red) ) ///
, graphregion(color(white)) plotregion(icolor(white)) ///
legend(order (6 5 3 2)  label(3 "Estimated Coefficient") label(1 "95% Confidence Interval")) ytitle("Log HHs Completed 100 Days") ///
xlabel(1 "<13C" 2 "13-15C" 3 "15-17C" 4 "17-19C" 5 "19-21C" 6 "21-23C" 7 "23-25C" 8 "25-27C" 9 "27-29C" 10 ">29C") ylabel(-0.04(0.02)0.04, angle (30))  
graph export "$output/F7b.png", replace width(800) height(600)	

restore

drop bincoef* 	 

areg lnexp_labor lbin1 lbin2 lbin4 lbin5 lbin6 lbin7 lbin8 lbin9 lbin10 lrain1 lrain3 lhumid1 lhumid4 i.year, absorb(gdistid) cluster(gdistid)
estimates store cT`table'C`col++'

foreach num of numlist 1 2 4 5 6 7 8 9 10{
gen bincoef`num' = _b[lbin`num']
gen bincoefcil`num' = _b[lbin`num'] - 1.96*_se[lbin`num']
gen bincoefciu`num' = _b[lbin`num'] + 1.96*_se[lbin`num']
}


gen bincoef3 = 0
gen bincoefcil3 = 0
gen bincoefciu3 = 0


preserve

keep bincoef* bincoefcil* bincoefciu*
gen id = _n

keep if id == 1

reshape long bincoef bincoefcil bincoefciu, i(id) j(ll1lbin)

label var bincoefcil "95% Confidence Interval"
label var bincoefciu "95% Confidence Interval"

label var ll1lbin "Daily Average Temperature (C)"

twoway (connected bincoefcil bincoefciu ll1lbin, astyle(ci ci) yline(0, lcolor(black))  mcolor(gray gray) lpattern(dash dash) lcolor(gray gray) sort) (connected bincoef ll1lbin, sort msymbol(O) lcolor(red) mcolor(red) ) ///
, graphregion(color(white)) plotregion(icolor(white)) ///
legend(order (6 5 3 2)  label(3 "Estimated Coefficient") label(1 "95% Confidence Interval")) ytitle("Log Expenditure Labor") ///
xlabel(1 "<13C" 2 "13-15C" 3 "15-17C" 4 "17-19C" 5 "19-21C" 6 "21-23C" 7 "23-25C" 8 "25-27C" 9 "27-29C" 10 ">29C") ylabel(-0.04(0.02)0.04, angle (30))  
graph export "$output/F7c.png", replace width(800) height(600)	

restore

drop bincoef* 	 

areg lnexp_material lbin1 lbin2 lbin4 lbin5 lbin6 lbin7 lbin8 lbin9 lbin10 lrain1 lrain3 lhumid1 lhumid4 i.year, absorb(gdistid) cluster(gdistid)
estimates store cT`table'C`col++'

foreach num of numlist 1 2 4 5 6 7 8 9 10{
gen bincoef`num' = _b[lbin`num']
gen bincoefcil`num' = _b[lbin`num'] - 1.96*_se[lbin`num']
gen bincoefciu`num' = _b[lbin`num'] + 1.96*_se[lbin`num']
}


gen bincoef3 = 0
gen bincoefcil3 = 0
gen bincoefciu3 = 0


preserve

keep bincoef* bincoefcil* bincoefciu*
gen id = _n

keep if id == 1

reshape long bincoef bincoefcil bincoefciu, i(id) j(ll1lbin)

label var bincoefcil "95% Confidence Interval"
label var bincoefciu "95% Confidence Interval"

label var ll1lbin "Daily Average Temperature (C)"

twoway (connected bincoefcil bincoefciu ll1lbin, astyle(ci ci) yline(0, lcolor(black))  mcolor(gray gray) lpattern(dash dash) lcolor(gray gray) sort) (connected bincoef ll1lbin, sort msymbol(O) lcolor(red) mcolor(red) ) ///
, graphregion(color(white)) plotregion(icolor(white)) ///
legend(order (6 5 3 2)  label(3 "Estimated Coefficient") label(1 "95% Confidence Interval")) ytitle("Log Expenditure Material") ///
xlabel(1 "<13C" 2 "13-15C" 3 "15-17C" 4 "17-19C" 5 "19-21C" 6 "21-23C" 7 "23-25C" 8 "25-27C" 9 "27-29C" 10 ">29C") ylabel(-0.04(0.02)0.04, angle (30))  
graph export "$output/F7d.png", replace width(800) height(600)	

restore

drop bincoef* 	 

